package com.health.myd;

import java.util.Date;
import java.util.List;

import com.health.NovaApplication;
import com.health.tablebean.JTYSDoctorEvaluateBean;
import com.health.tools.GlobalConts;
import com.health.tools.SPUtil;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;

/**
 * 解析服务项目包
 * 
 * @author nova
 *
 */
public class GlobcontsFWMYD {
	
	public static void saveFWMYD(Context ctx,String cardNum,String serviceItem,String pjContent,String isOutpatients  ){
		List<JTYSDoctorEvaluateBean> evaluates=NovaApplication.fdbmanger.findAllByWhere(JTYSDoctorEvaluateBean.class, "cardNum='"+cardNum+"'"
				+ " and serviceItem='"+serviceItem+"'");
		JTYSDoctorEvaluateBean evaluate  = new JTYSDoctorEvaluateBean();
		if(evaluates.size()>0){
			NovaApplication.fdbmanger.deleteByWhere(JTYSDoctorEvaluateBean.class, "cardNum='"+cardNum+"'"
				+ " and serviceItem='"+serviceItem+"'");
		} 
		evaluate.setId(GlobalConts.getUUID());
//		String str_jddw = sp.getString("str_jddw", "");
//		String str_jddwno = sp.getString("str_jddwno", "");
//		String str_jdrUserName = sp.getString("str_jdrUserName", "");
		String str_jddw = SPUtil.getstr_jddw(ctx); 
		String str_jddwno = SPUtil.getStrjddwno(ctx); 
		String str_jdrUserName = SPUtil.getstr_jdrusername(ctx); 
		evaluate.setOfficeId(str_jddwno);
		evaluate.setOfficeName(str_jddw);
		String datetimeNow = GlobalConts.datetimeFormat.format(new Date());
		evaluate.setSatisfiedState(pjContent);
		evaluate.setLoginName(str_jdrUserName);
		evaluate.setCardNum(cardNum);
		evaluate.setSign("0");
		evaluate.setSource("0");
		
		evaluate.setCommentator(NovaApplication.getUserInfo().getCUSTOMERNAME());
		evaluate.setServiceItem(serviceItem);
		evaluate.setServiceTime(datetimeNow);
		evaluate.setSatisfiedTime(datetimeNow);
		evaluate.setIsOutpatients(isOutpatients);

		evaluate.setCreatedate(datetimeNow);
		evaluate.setCreater(NovaApplication.getJgrno());
		evaluate.setUpdatedate(datetimeNow);
		evaluate.setUpdater(NovaApplication.getJgrno());
		Log.e("eeeee+添加", evaluate.toString());
		NovaApplication.fdbmanger.save(evaluate);
//		if(tag==-1){
//			
//			Log.e("eeeee+添加", evaluate.toString());
//			NovaApplication.fdbmanger.save(evaluate);
//		} else if(tag==0){
//			
//			Log.e("eeeee+修改", evaluate.toString());
//			NovaApplication.fdbmanger.updata(JTYSDoctorEvaluateBean.class,
//					 "id='"+id+"'"); 
//		}
		
	}
	 
}
